package com.zuilapsa.jmc.userInterfaces;

import org.dom4j.Element;

import com.zuilapsa.jmc.JmcException;
import com.zuilapsa.jmc.model.Level;

/*******************************************************************************
 * InterfaceSession - just for internal usage
 ******************************************************************************/
public class SystemInterfaceSession implements UserInterfaceSession {
	Level level = null;

	public SystemInterfaceSession() {
		try {
			level = Level.getRootInstance();
		} catch (JmcException e) {
			printMessageError(e.getMessage());
		}
	}

	public Element getConfigElement() {
		return level.getConfigElement();
	}

	public Element getDefinitionElement() {
		return level.getDefinitionElement();
	}

	public Level getLevel() {
		return level;
	}

	public Level getModel() {
		try {
			return Level.getRootInstance();
		} catch (JmcException e) {
			printMessageError(e.getMessage());
			return null;
		}
	}

	public void printMessageError(String message) {
		System.err.println("ERROR:" + message);
	}

	public void printMessageInfo(String message) {
		System.out.println("INFO: " + message);
	}

	public void printMessageWarning(String message) {
		System.out.println("WARNING: " + message);
	}

	public void setLevel(Level level) {
		this.level = level;
	}

	public void startStopping() {
		// not a thread - function is just not applicable
	}

}
